//定义表示记分牌的类
class ScorePanel{
    //score和level用来记录分数和等级
    score = 0
    level = 1
    scoreELe:HTMLElement
    levelEle:HTMLElement

    // 设置一个变量限制等级
    maxLevel:number
    // 设置一个变量表示多少分时升级
    upScore:number
    constructor(maxLevel:number=10,upScore:number=10) {
        this.scoreELe = document.getElementById('score')!
        this.levelEle = document.getElementById('level')!
        this.maxLevel = maxLevel
        this.upScore = upScore
    }
    //设置一个加分的方法
    addScore(){
        this.scoreELe.innerHTML = ++this.score+''
        //判断分数多少
        if(this.score %this.upScore === 0){
            this.levelUp()
        }
    }

    // 提升等级的方法
    levelUp(){
        if(this.level<this.maxLevel){
            this.levelEle.innerHTML = ++this.level+''
        }
    }
}

// const scorePanel = new ScorePanel()
// scorePanel.addScore()
export default ScorePanel